<!DOCTYPE html> <html lang=zh-cn style><!--
 Page saved with SingleFile 
 url: https://www.cnblogs.com/ysocean/p/6870069.html 
 saved date: Thu Dec 05 2019 09:44:11 GMT+0800 (中国标准时间)
--><meta charset=utf-8>
<meta name=viewport content="width=device-width, initial-scale=1.0">
<meta name=referrer content=origin>
<meta property=og:description content=Java的序列化与反序列化>
<meta http-equiv=Cache-Control content=no-transform>
<meta http-equiv=Cache-Control content=no-siteapp>
<meta http-equiv=X-UA-Compatible content="IE=edge">
<title>Java IO详解（六)------序列化与反序列化（对象流） - YSOcean - 博客园</title>
<style>.syntaxhighlighter div,.syntaxhighlighter code,.syntaxhighlighter table,.syntaxhighlighter table td,.syntaxhighlighter table tr,.syntaxhighlighter table tbody{-moz-border-radius:0 0 0 0!important;-webkit-border-radius:0 0 0 0!important;background:none!important;border:0!important;bottom:auto!important;float:none!important;height:auto!important;left:auto!important;line-height:1.1em!important;margin:0!important;outline:0!important;overflow:visible!important;padding:0!important;position:static!important;right:auto!important;text-align:left!important;top:auto!important;vertical-align:baseline!important;width:auto!important;box-sizing:content-box!important;font-family:"Consolas","Bitstream Vera Sans Mono","Courier New",Courier,monospace!important;font-weight:normal!important;font-style:normal!important;font-size:1em!important;min-height:inherit!important;min-height:auto!important}.syntaxhighlighter{width:100%!important;margin:1em 0 1em 0!important;position:relative!important;overflow:auto!important;font-size:1em!important}.syntaxhighlighter .line{white-space:pre!important}.syntaxhighlighter table{width:100%!important}.syntaxhighlighter table td.code{width:100%!important}.syntaxhighlighter table td.code .container{position:relative!important}.syntaxhighlighter table td.gutter .line{text-align:right!important;padding:0 .5em 0 1em!important}.syntaxhighlighter table td.code .line{padding:0 1em!important}.syntaxhighlighter{background-color:#fff!important}.syntaxhighlighter .line.alt1{background-color:#fff!important}.syntaxhighlighter .gutter{color:#afafaf!important}.syntaxhighlighter .gutter .line{border-right:3px solid #6ce26c!important}.syntaxhighlighter .plain{color:#000!important}.syntaxhighlighter .comments{color:#008200!important}.syntaxhighlighter .string{color:#00f!important}.syntaxhighlighter .keyword{color:#069!important}.syntaxhighlighter .value{color:#090!important}.syntaxhighlighter .color1{color:#808080!important}.syntaxhighlighter .keyword{font-weight:bold!important}.syntaxhighlighter code{white-space:-moz-pre-wrap!important;white-space:-o-pre-wrap}.syntaxhighlighter .line{white-space:normal!important;line-height:1.8em!important}.syntaxhighlighter code{line-height:1.8em!important}.syntaxhighlighter table td.code{width:auto!important}.syntaxhighlighter .line.alt2{background-color:#f4f4f4!important}.syntaxhighlighter .gutter{width:35px!important}.syntaxhighlighter .gutter .line{border-right:2px solid #6ce26c!important}.syntaxhighlighter table td.gutter .line{padding:0 .5em 0 .5em!important;text-align:right!important}.syntaxhighlighter .keyword{font-weight:normal!important;color:#00f!important}.syntaxhighlighter div,.syntaxhighlighter code,.syntaxhighlighter table,.syntaxhighlighter table td,.syntaxhighlighter table tr,.syntaxhighlighter table tbody{font-size:12px!important}.sh-gutter .line,.sh-gutter code{white-space:nowrap!important}#blog_post_info_block{margin-top:20px}#BlogPostCategory{margin-bottom:10px}#EntryTag{margin-top:0!important}.login_tips{background-image:url();background-repeat:no-repeat;margin-top:10px;padding:0 0 10px 25px;font-weight:bold}.login_tips a{text-decoration:underline!important}#comment_nav{text-align:right}#comment_nav a{padding-left:10px}#author_profile{float:left;width:280px;margin-top:0;margin-bottom:10px;color:#000;margin-left:0;font-size:12px}#author_profile a:hover{text-decoration:underline}.author_avatar{vertical-align:top;float:left;margin-right:5px;padding-top:5px;padding-left:2px;border:0}.author_profile_info{float:left;line-height:18px}#div_digg{float:right;margin-bottom:10px;margin-right:30px;font-size:12px;width:125px;text-align:center;margin-top:10px}.diggit{float:left;width:46px;height:52px;background:url() no-repeat;text-align:center;cursor:pointer;margin-top:2px;padding-top:5px}.diggnum{font-size:14px;color:#075db3;font-family:Verdana}.burynum{font-size:14px;color:#075db3;font-family:Verdana}.diggword{margin-top:5px;margin-left:0;font-size:12px;color:gray}#profile_block{margin-top:5px;line-height:1.5;text-align:left}.blog_comment_body{word-wrap:break-word;overflow:hidden}#post_next_prev{line-height:1.8;font-size:12px}#post_next_prev a.p_n_p_prefix:link{text-decoration:none}#post_next_prev a.p_n_p_prefix:hover{text-decoration:underline}#green_channel{padding:10px 0;margin-bottom:10px;margin-top:10px;border:#c0c0c0 1px dashed;font-size:12px;width:350px;text-align:center}#green_channel a{background:url(%3D%3D) repeat-x;display:inline-block;padding:3px 8px;color:#fff;text-decoration:none;font-weight:bold;cursor:pointer;margin-right:10px;-moz-border-radius:5px;-webkit-border-radius:10px;-moz-box-shadow:0 1px 3px rgba(0,0,0,.5);-webkit-box-shadow:0 1px 3px rgba(0,0,0,.5);text-shadow:0 -1px 1px rgba(0,0,0,.25);vertical-align:middle}#green_channel a:hover{background-image:url()}#green_channel #green_channel_digg{background-color:#2daebf}#green_channel #green_channel_follow{background-color:#e33100}#green_channel #green_channel_favorite{background-color:#ffb515}#green_channel #green_channel_weibo img{vertical-align:middle;border:0;margin-left:5px;box-shadow:none}#green_channel #green_channel_weibo,#green_channel #green_channel_wechat{background:0;padding:3px 2px;-moz-border-radius:none;-webkit-border-radius:none;-moz-box-shadow:none;-webkit-box-shadow:none;text-shadow:none}#green_channel #green_channel_wechat img{width:24px;height:24px;border:medium none;box-shadow:none;margin-left:5px;vertical-align:middle}#cnblogs_post_body{margin-bottom:20px}#cnblogs_post_body table{border:1px solid silver;border-collapse:collapse;word-break:break-word}#cnblogs_post_body td{border:1px solid silver;border-collapse:collapse;padding:8px 14px}#cnblogs_post_body img{max-width:900px;height:auto}.ad_text_commentbox{margin-top:5px;margin-bottom:5px}#ad_t2{margin-top:5px;line-height:1.8}#ad_t2 a{margin-right:10px}#opt_under_post{line-height:1.8}.recent_comment_author{text-align:right;margin-right:4px}.Cal{width:100%}.comment_vote{text-align:right}.comment_vote a{text-decoration:none!important;padding-left:10px}.recent_comment_body{white-space:pre-wrap;word-wrap:break-word}#cnblogs_post_body{word-break:break-word}#cnblogs_post_body p{margin:10px auto;text-indent:0}#div_digg .diggnum{line-height:1.5em!important}#div_digg .burynum{line-height:1.5em!important}#green_channel a:link,#green_channel a:visited,#green_channel a:active{color:#fff!important;border:none!important}#blog-news{overflow:hidden}@-webkit-keyframes ui-dialog-loading{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg)}}@keyframes ui-dialog-loading{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}#EntryTag{margin-top:20px;font-size:9pt}*{margin:0;padding:0}html{height:100%}body{color:#000;background:#d2d8de;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:14px;min-height:101%}table{border-collapse:collapse;border-spacing:0}img{border:0}ul{word-break:break-all}li{list-style:none}h2,h3{font-size:100%;font-weight:normal}a:link{color:black;text-decoration:none}a:visited{color:black;text-decoration:none}a:hover{color:#F60;text-decoration:underline}a:active{color:black;text-decoration:none}.clear{clear:both}#home{margin:0 auto}#blogTitle{height:70px;background:#fafcfd;clear:both}#blogTitle h1{font-size:150%;font-weight:bold;line-height:1.5;margin-left:1em;margin-top:10px;width:50%;float:left}#blogTitle h2{margin-left:4em;line-height:1.5;width:50%;float:left}#blogLogo{float:right}#navigator{background-color:#169fe6;height:60px;line-height:60px;overflow:hidden;clear:both}#navList{min-height:30px;float:left}#navList li{float:left}#navList a{display:block;padding:0 1.5em;height:60px;font-family:'微软雅黑';float:left;font-size:1.2em;text-align:center;transition-duration:.3s}#navList a:link,#navList a:visited,#navList a:active{color:#fafcfd}#navList a:hover{color:white;background-color:#343434;text-decoration:none;text-shadow:0px 0px 1px #000}.blogStats{float:right;color:#ccc;padding-right:10px;text-align:right}#main{min-width:950px;text-align:left;padding:20px 0 0 20px;overflow:hidden}#mainContent .forFlow{margin-left:20em;float:none;width:auto}#mainContent{min-height:200px;padding:0px 0px 10px 0;-o-text-overflow:ellipsis;text-overflow:ellipsis;overflow:hidden;word-break:break-all;float:left;margin-left:-20em;margin-right:20px;display:inline;width:100%}.postTitle{clear:both}.postTitle a:link,.postTitle a:visited,.postTitle a:active{color:#390;transition:all .4s linear 0s}.postTitle a:hover{color:#F60;text-decoration:none;margin-left:10px}.postDesc{clear:both;line-height:2.5em}.postDesc a:link,.postDesc a:visited,.postDesc a:active{color:#666}.postDesc a:hover{color:#F60;text-decoration:none}#sideBar{width:230px;min-height:200px;padding:0px 0 0px 5px;float:right;-o-text-overflow:ellipsis;text-overflow:ellipsis;overflow:hidden;word-break:break-all;margin-right:20px}#sideBar .catListTitle{background-color:#308ebb;color:#fff;font-size:20px;margin-top:0;padding:10px 30px;text-align:center}#sideBar .newsItem #profile_block{color:#666;font-family:Georgia,"Times New Roman",Times,sans-serif;font-size:18px;padding:20px}#sideBar .newsItem{background-color:#fff;border-radius:5px;box-shadow:0 0 3px rgba(0,0,0,0.2);margin:0 0 20px;overflow:hidden}.newsItem,#blog-calendar{margin-bottom:15px;text-indent:0;padding:10px;background:#fafcfd;border-radius:7px;box-shadow:1px 1px 2px #a7a8ad;line-height:1.5}.Cal{border:0;color:#666}.CalTodayDay{color:#f60}.CalDayHeader{border-bottom:1px solid #ccc}.CalTitle{width:100%;background:white;color:black;border-bottom:1px solid #666}.catListTitle{background:#390;border-bottom:1px solid #060;border-top-left-radius:7px;border-top-right-radius:7px;height:1.8em;line-height:1.8em;text-indent:.5em;text-shadow:1px 1px 0 rgba(0,0,0,0.3)}.catListComment{line-height:1.5}#sideBarMain ul{line-height:1.5}.catListTag,.catListPostCategory,.catListView,.catListComment,.catListBlogRank{margin-bottom:15px;background:#fafcfd;border-radius:7px;box-shadow:1px 1px 2px #a7a8ad;overflow:hidden;zoom:1}.catListTag ul li,.catListPostCategory ul li,.catListView ul li,.catListComment ul li,.catListBlogRank ul li{text-indent:1em;padding:10px 5px;border-bottom:1px solid #dadfe1;border-top:1px solid #fff;overflow:hidden}.catListTag ul li a,.catListPostCategory ul li a,.catListView ul li a,.catListComment ul li a{text-indent:1em;font-size:15px}.catListEssay ul li a:hover,.catListLink ul li a:hover,.catListNoteBook ul li a:hover,.catListTag ul li a:hover,.catListPostCategory ul li a:hover,.catListPostArchive ul li a:hover,.catListImageCategory ul li a:hover,.catListView ul li a:hover,.catListFeedback ul li a:hover,.catListArticleArchive ul li a:hover,.catListComment ul li a:hover{text-decoration:none}#topics{min-height:200px;margin-bottom:15px;padding:15px;-o-text-overflow:ellipsis;text-overflow:ellipsis;overflow:hidden;word-break:break-all;background:#fff;border-radius:7px;box-shadow:1px 1px 2px #a7a8ad}#topics .postTitle{font-size:130%;font-weight:bold;border-bottom:1px solid #999;float:left;line-height:2em;width:100%;padding-left:5px}.postBody{padding:15px 2px 5px 5px;color:#000;border-bottom:1px solid #ccc}#EntryTag{color:#666}#EntryTag a{margin-left:5px}#EntryTag a:link,#EntryTag a:visited,#EntryTag a:active{color:#666}#EntryTag a:hover{color:#f60}#topics .postDesc{float:right;width:100%;text-align:right;padding-right:5px;color:#666;margin-top:5px}.feedback_area_title{font-weight:bold;line-height:35px;margin:10px 0;border-bottom:1px solid #ccc;padding-left:8px}.feedbackListSubtitle{color:#666}.feedbackListSubtitle a:link,.feedbackListSubtitle a:visited,.feedbackListSubtitle a:active{color:#666;font-weight:normal}.feedbackListSubtitle a:hover{color:#f60;text-decoration:none}.feedbackManage{width:200px;text-align:right;float:right}.feedbackCon{border-bottom:1px solid #ccc;padding:20px 18px 10px 40px;min-height:35px;margin-bottom:1em;line-height:1.5}#footer{text-align:center;min-height:15px;border-top:1px solid black;margin-top:10px;padding-top:10px;margin-bottom:10px}.postBody{line-height:1.5}.postBody a:link,.postBody a:visited,.postBody a:active{text-decoration:underline}#cnblogs_post_body{color:black;font:.875em/1.5em "微软雅黑","PTSans","Arial",sans-serif;font-size:15px}#MySignature{border:solid 1px #e5e5e5;padding:10px;background:#e5eef7 url() no-repeat scroll 15px 50%;padding-left:80px}#MySignature div{line-height:20px}</style>
<style media="only screen and (max-width: 767px)">body{font-size:14px!important;font-family:'PingFang SC','Helvetica Neue','Helvetica','Arial',sans-serif;-webkit-text-size-adjust:none}img{max-width:300px!important;height:auto}#green_channel{width:320px}#cnblogs_post_body table{display:block;overflow-x:scroll;-webkit-overflow-scrolling:regular}#cnblogs_post_body td{white-space:nowrap}#cnblogs_post_body table::-webkit-scrollbar:horizontal{height:12px}#cnblogs_post_body table::-webkit-scrollbar-track{-webkit-box-shadow:inset 0 0 6px rgba(0,0,0,.3);border-radius:10px;background-color:#f5f5f5}#cnblogs_post_body table::-webkit-scrollbar{width:12px;background-color:#f5f5f5}#cnblogs_post_body table::-webkit-scrollbar-thumb{border-radius:10px;-webkit-box-shadow:inset 0 0 6px rgba(0,0,0,.3);background-color:#555}.commentform{margin-left:10px}#main{min-width:auto!important;padding-left:0!important;width:auto!important;padding-right:5px}#navigator{width:auto!important}#sideBar{width:auto!important}#mainContent{margin-left:0!important;float:none!important}#mainContent .forFlow{margin-left:5px!important}#comment_form{padding-left:10px!important}#blogTitle h1{width:auto!important}#home{width:auto}</style>
<link type=application/rss+xml rel=alternate href=https://www.cnblogs.com/ysocean/rss>
<link type=application/rsd+xml rel=EditURI href=https://www.cnblogs.com/ysocean/rsd.xml>
<link type=application/wlwmanifest+xml rel=wlwmanifest href=https://www.cnblogs.com/ysocean/wlwmanifest.xml>
<style>#MathJax_Message{position:fixed;left:1em;bottom:1.5em;background-color:#E6E6E6;border:1px solid #959595;margin:0px;padding:2px 8px;z-index:102;color:black;font-size:80%;width:auto;white-space:nowrap}</style><link type=image/x-icon rel="shortcut icon" href=><style>.sf-hidden{display:none!important}</style></head>
<body><div id=MathJax_Message style=display:none></div>
 <a name=top></a>
 
 
<div id=home>
<div id=header>
 <div id=blogTitle>
 <a id=lnkBlogLogo href=https://www.cnblogs.com/ysocean/><img id=blogLogo src="" alt=返回主页></a> 
 
<h1><a id=Header1_HeaderTitle class="headermaintitle HeaderMainTitle" href=https://www.cnblogs.com/ysocean/>YSOcean</a>
</h1>
<h2>
</h2>
 
 </div>
 <div id=navigator>
 
<ul id=navList>
<li><a id=blog_nav_sitehome class=menu href=https://www.cnblogs.com/>
博客园</a>
</li>
<li>
</li>
<li>
</li>
<li>
<a id=blog_nav_contact class=menu href=https://msg.cnblogs.com/send/YSOcean>
联系</a></li>
<li>
</li>
<li>
<a id=blog_nav_admin class=menu href=https://i.cnblogs.com/>
管理</a>
</li>
</ul>
 <div class=blogStats>
 
 <span id=stats_post_count>随笔 - 
215&nbsp; </span>
<span id=stats_article_count>文章 - 
0&nbsp; </span>
<span id=stats-comment_count>评论 - 
922</span>
 
 </div>
 </div>
</div>
<div id=main>
 <div id=mainContent>
 <div class=forFlow>
 <div id=post_detail>
 
 <div id=topics>
 <div class=post>
 <h1 class=postTitle>
 
<a id=cb_post_title_url class=postTitle2 href=https://www.cnblogs.com/ysocean/p/6870069.html>Java IO详解（六)------序列化与反序列化（对象流）</a>
 </h1>
 <div class=clear></div>
 <div class=postBody>
 
<div id=cnblogs_post_body class=blogpost-body>
 <p>File 类的介绍：<a href=http://www.cnblogs.com/ysocean/p/6851878.html target=_blank>http://www.cnblogs.com/ysocean/p/6851878.html</a></p>
<p>Java IO 流的分类介绍：<a href=http://www.cnblogs.com/ysocean/p/6854098.html target=_blank>http://www.cnblogs.com/ysocean/p/6854098.html</a></p>
<p>Java IO 字节输入输出流：<a href=http://www.cnblogs.com/ysocean/p/6854541.html target=_blank>http://www.cnblogs.com/ysocean/p/6854541.html</a></p>
<p>Java IO 字符输入输出流：<a href="https://i.cnblogs.com/EditPosts.aspx?postid=6859242" target=_blank>https://i.cnblogs.com/EditPosts.aspx?postid=6859242</a></p>
<p>Java IO 包装流：<a href=http://www.cnblogs.com/ysocean/p/6864080.html target=_blank>http://www.cnblogs.com/ysocean/p/6864080.html</a></p>
<p>&nbsp;</p>
<p><strong>1、什么是序列化与反序列化？</strong></p>
<p><strong>　　</strong>序列化：指把堆内存中的 Java 对象数据，通过某种方式把对象存储到磁盘文件中或者传递给其他网络节点（在网络上传输）。这个过程称为序列化。通俗来说就是将数据结构或对象转换成二进制串的过程</p>
<p>　　反序列化：把磁盘文件中的对象数据或者把网络节点上的对象数据，恢复成Java对象模型的过程。也就是将在序列化过程中所生成的二进制串转换成数据结构或者对象的过程</p>
<p>&nbsp;</p>
<p><strong>2、为什么要做序列化？</strong></p>
<p>　　①、在分布式系统中，此时需要把对象在网络上传输，就得把对象数据转换为二进制形式，需要共享的数据的 JavaBean 对象，都得做序列化。</p>
<p>　　②、服务器钝化：如果服务器发现某些对象好久没活动了，那么服务器就会把这些内存中的对象持久化在本地磁盘文件中（Java对象转换为二进制文件）；如果服务器发现某些对象需要活动时，先去内存中寻找，找不到再去磁盘文件中反序列化我们的对象数据，恢复成 Java 对象。这样能节省服务器内存。</p>
<p>&nbsp;</p>
<p><strong>3、Java 怎么进行序列化？</strong></p>
<p>　　①、需要做序列化的对象的类，必须实现序列化接口：Java.lang.Serializable 接口（这是一个标志接口，没有任何抽象方法），Java 中大多数类都实现了该接口，比如：String，Integer</p>
<p>　　②、底层会判断，如果当前对象是 Serializable 的实例，才允许做序列化，Java对象 instanceof Serializable 来判断。</p>
<p>　　③、在 Java 中使用对象流来完成序列化和反序列化</p>
<p>　　　　<strong>ObjectOutputStream</strong>:通过 writeObject()方法做序列化操作</p>
<p>　　　　<strong>ObjectInputStream</strong>:通过 readObject() 方法做反序列化操作</p>
<p><strong>　　　　<img src="" alt></strong></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>&nbsp;第一步：创建一个 JavaBean 对象</strong></p>
<div class="cnblogs_Highlighter sh-gutter">
<div><div id=highlighter_646434 class="syntaxhighlighter java"><div class="toolbar sf-hidden"><span></span></div><table border=0 cellpadding=0 cellspacing=0><tbody><tr><td class=gutter><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div><div class="line number11 index10 alt2">11</div><div class="line number12 index11 alt1">12</div><div class="line number13 index12 alt2">13</div><div class="line number14 index13 alt1">14</div><div class="line number15 index14 alt2">15</div><div class="line number16 index15 alt1">16</div><div class="line number17 index16 alt2">17</div><div class="line number18 index17 alt1">18</div><div class="line number19 index18 alt2">19</div><div class="line number20 index19 alt1">20</div><div class="line number21 index20 alt2">21</div><div class="line number22 index21 alt1">22</div><div class="line number23 index22 alt2">23</div><div class="line number24 index23 alt1">24</div><div class="line number25 index24 alt2">25</div><div class="line number26 index25 alt1">26</div><td class=code><div class=container><div class="line number1 index0 alt2"><code class="java keyword">public</code> <code class="java keyword">class</code> <code class="java plain">Person </code><code class="java keyword">implements</code> <code class="java plain">Serializable{</code></div><div class="line number2 index1 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">private</code> <code class="java plain">String name;</code></div><div class="line number3 index2 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">private</code> <code class="java keyword">int</code> <code class="java plain">age;</code></div><div class="line number4 index3 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code>&nbsp;</div><div class="line number5 index4 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">public</code> <code class="java plain">String getName() {</code></div><div class="line number6 index5 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">return</code> <code class="java plain">name;</code></div><div class="line number7 index6 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number8 index7 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">public</code> <code class="java keyword">void</code> <code class="java plain">setName(String name) {</code></div><div class="line number9 index8 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">this</code><code class="java plain">.name = name;</code></div><div class="line number10 index9 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number11 index10 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">public</code> <code class="java keyword">int</code> <code class="java plain">getAge() {</code></div><div class="line number12 index11 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">return</code> <code class="java plain">age;</code></div><div class="line number13 index12 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number14 index13 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">public</code> <code class="java keyword">void</code> <code class="java plain">setAge(</code><code class="java keyword">int</code> <code class="java plain">age) {</code></div><div class="line number15 index14 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">this</code><code class="java plain">.age = age;</code></div><div class="line number16 index15 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number17 index16 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java color1">@Override</code></div><div class="line number18 index17 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">public</code> <code class="java plain">String toString() {</code></div><div class="line number19 index18 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">return</code> <code class="java string">"Person [name="</code> <code class="java plain">+ name + </code><code class="java string">", age="</code> <code class="java plain">+ age + </code><code class="java string">"]"</code><code class="java plain">;</code></div><div class="line number20 index19 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number21 index20 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">public</code> <code class="java plain">Person(String name, </code><code class="java keyword">int</code> <code class="java plain">age) {</code></div><div class="line number22 index21 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">super</code><code class="java plain">();</code></div><div class="line number23 index22 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">this</code><code class="java plain">.name = name;</code></div><div class="line number24 index23 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">this</code><code class="java plain">.age = age;</code></div><div class="line number25 index24 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number26 index25 alt1"><code class="java plain">}　　</code></div></div></table></div></div>
</div>
<p>&nbsp;</p>
<p><strong>&nbsp;第二步：使用 ObjectOutputStream 对象实现序列化</strong></p>
<div class="cnblogs_Highlighter sh-gutter">
<div><div id=highlighter_301774 class="syntaxhighlighter java"><div class="toolbar sf-hidden"><span></span></div><table border=0 cellpadding=0 cellspacing=0><tbody><tr><td class=gutter><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><td class=code><div class=container><div class="line number1 index0 alt2"><code class="java comments">//在根目录下新建一个 io 的文件夹</code></div><div class="line number2 index1 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">OutputStream op = </code><code class="java keyword">new</code> <code class="java plain">FileOutputStream(</code><code class="java string">"io"</code><code class="java plain">+File.separator+</code><code class="java string">"a.txt"</code><code class="java plain">);</code></div><div class="line number3 index2 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">ObjectOutputStream ops = </code><code class="java keyword">new</code> <code class="java plain">ObjectOutputStream(op);</code></div><div class="line number4 index3 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">ops.writeObject(</code><code class="java keyword">new</code> <code class="java plain">Person(</code><code class="java string">"vae"</code><code class="java plain">,</code><code class="java value">1</code><code class="java plain">));</code></div><div class="line number5 index4 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code>&nbsp;</div><div class="line number6 index5 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">ops.close();</code></div></div></table></div></div>
</div>
<p>　　我们打开 a.txt 文件，发现里面的内容乱码，注意这不需要我们来看懂，这是二进制文件，计算机能读懂就行了。</p>
<p>错误一：如果新建的 Person 对象没有实现&nbsp;Serializable 接口，那么上面的操作会报错：</p>
<p>　　　　<img src="" alt></p>
<p><strong>第三步：使用ObjectInputStream 对象实现反序列化</strong></p>
<p><strong>　　反序列化的对象必须要提供该对象的字节码文件.class</strong></p>
<div class="cnblogs_Highlighter sh-gutter">
<div><div id=highlighter_548181 class="syntaxhighlighter java"><div class="toolbar sf-hidden"><span></span></div><table border=0 cellpadding=0 cellspacing=0><tbody><tr><td class=gutter><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><td class=code><div class=container><div class="line number1 index0 alt2"><code class="java plain">InputStream in = </code><code class="java keyword">new</code> <code class="java plain">FileInputStream(</code><code class="java string">"io"</code><code class="java plain">+File.separator+</code><code class="java string">"a.txt"</code><code class="java plain">);</code></div><div class="line number2 index1 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">ObjectInputStream os = </code><code class="java keyword">new</code> <code class="java plain">ObjectInputStream(in);</code></div><div class="line number3 index2 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">byte</code><code class="java plain">[] buffer = </code><code class="java keyword">new</code> <code class="java keyword">byte</code><code class="java plain">[</code><code class="java value">10</code><code class="java plain">];</code></div><div class="line number4 index3 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">int</code> <code class="java plain">len = -</code><code class="java value">1</code><code class="java plain">;</code></div><div class="line number5 index4 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">Person p = (Person) os.readObject();</code></div><div class="line number6 index5 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">System.out.println(p);&nbsp; </code><code class="java comments">//Person [name=vae, age=1]</code></div><div class="line number7 index6 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">os.close();</code></div></div></table></div></div>
</div>
<p>　　</p>
<p>问题1：如果某些数据不需要做序列化，比如密码，比如上面的年龄？</p>
<p>解决办法：在字段面前加上&nbsp;transient</p>
<div class="cnblogs_Highlighter sh-gutter">
<div><div id=highlighter_410009 class="syntaxhighlighter java"><div class="toolbar sf-hidden"><span></span></div><table border=0 cellpadding=0 cellspacing=0><tbody><tr><td class=gutter><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><td class=code><div class=container><div class="line number1 index0 alt2"><code class="java keyword">private</code> <code class="java plain">String name;</code><code class="java comments">//需要序列化</code></div><div class="line number2 index1 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">transient</code> <code class="java keyword">private</code> <code class="java keyword">int</code> <code class="java plain">age;</code><code class="java comments">//不需要序列化</code></div></div></table></div></div>
</div>
<p>　　那么我们在反序列化的时候，打印出来的就是Person [name=vae, age=0]，整型数据默认值为 0&nbsp;</p>
<p>&nbsp;</p>
<p>问题2：序列化版本问题，在完成序列化操作后，由于项目的升级或修改，可能我们会对序列化对象进行修改，比如增加某个字段，那么我们在进行反序列化就会报错：</p>
<p><img src="" alt></p>
<p>&nbsp;</p>
<p>&nbsp;<img src="" alt></p>
<p>解决办法：在 JavaBean 对象中增加一个 serialVersionUID 字段，用来固定这个版本，无论我们怎么修改，版本都是一致的，就能进行反序列化了</p>
<div class="cnblogs_Highlighter sh-gutter">
<div><div id=highlighter_998871 class="syntaxhighlighter java"><div class="toolbar sf-hidden"><span></span></div><table border=0 cellpadding=0 cellspacing=0><tbody><tr><td class=gutter><div class="line number1 index0 alt2">1</div><td class=code><div class=container><div class="line number1 index0 alt2"><code class="java keyword">private</code> <code class="java keyword">static</code> <code class="java keyword">final</code> <code class="java keyword">long</code> <code class="java plain">serialVersionUID = 8656128222714547171L;</code></div></div></table></div></div>
</div>
<p>　　</p>
<p>&nbsp;</p>
</div>
<div id=MySignature style=display:block><div>作者：<a href=http://www.cnblogs.com/ysocean/ target=_blank>YSOcean</a></div>
<div>出处：<a href=http://www.cnblogs.com/ysocean/ target=_blank>http://www.cnblogs.com/ysocean/</a></div>
<div>本文版权归作者所有，欢迎转载，但未经作者同意不能转载，否则保留追究法律责任的权利。 </div></div>
<div class=clear></div>
<div id=blog_post_info_block><div id=BlogPostCategory>
 分类: 
 <a href=https://www.cnblogs.com/ysocean/category/960781.html target=_blank>Java SE</a></div>
<div id=EntryTag>
 标签: 
 <a href=https://www.cnblogs.com/ysocean/tag/Java%20IO%E8%AF%A6%E8%A7%A3%E7%B3%BB%E5%88%97/>Java IO详解系列</a></div>
 <div id=blog_post_info>
<div id=green_channel>
 <a href=https://www.cnblogs.com/ysocean/p/6870069.html id=green_channel_digg>好文要顶</a>
 <a id=green_channel_follow href=https://www.cnblogs.com/ysocean/p/6870069.html>关注我</a>
 <a id=green_channel_favorite href=https://www.cnblogs.com/ysocean/p/6870069.html>收藏该文</a>
 <a id=green_channel_weibo href=https://www.cnblogs.com/ysocean/p/6870069.html title=分享至新浪微博><img src= alt></a>
 <a id=green_channel_wechat href=https://www.cnblogs.com/ysocean/p/6870069.html title=分享至微信><img src= alt></a>
</div>
<div id=author_profile>
 <div id=author_profile_info class=author_profile_info>
 <a href=https://home.cnblogs.com/u/ysocean/ target=_blank><img src="" class=author_avatar alt></a>
 <div id=author_profile_detail class=author_profile_info>
 <a href=https://home.cnblogs.com/u/ysocean/>YSOcean</a><br>
 <a href=https://home.cnblogs.com/u/ysocean/followees/>关注 - 13</a><br>
 <a href=https://home.cnblogs.com/u/ysocean/followers/>粉丝 - 3709</a>
 </div>
 </div>
 <div class=clear></div>
 <div id=author_profile_honor></div>
 <div id=author_profile_follow>
 <a href=https://www.cnblogs.com/ysocean/p/6870069.html>+加关注</a>
 </div>
</div>
<div id=div_digg>
 <div class=diggit>
 <span class=diggnum id=digg_count>9</span>
 </div>
 <div class="buryit sf-hidden">
 <span class=burynum id=bury_count>0</span>
 </div>
 <div class=clear></div>
 <div class=diggword id=digg_tips>
 </div>
</div>
</div>
 <div class=clear></div>
 <div id=post_next_prev>
 <a href=https://www.cnblogs.com/ysocean/p/6864080.html class=p_n_p_prefix>« </a> 上一篇： <a href=https://www.cnblogs.com/ysocean/p/6864080.html title="发布于 2017-05-16 22:31">Java IO详解（五)------包装流</a>
 <br>
 <a href=https://www.cnblogs.com/ysocean/p/6870250.html class=p_n_p_prefix>» </a> 下一篇： <a href=https://www.cnblogs.com/ysocean/p/6870250.html title="发布于 2017-05-18 20:25">Java IO详解（七)------随机访问文件流</a>
</div>
</div>
 </div>
 <div class=postDesc>posted @ 
<span id=post-date>2017-05-17 23:13</span>&nbsp;
<a href=https://www.cnblogs.com/ysocean/>YSOcean</a>&nbsp;
阅读(<span id=post_view_count>28877</span>)&nbsp;
评论(<span id=post_comment_count>3</span>)&nbsp;
<a href="https://i.cnblogs.com/EditPosts.aspx?postid=6870069" rel=nofollow>
 编辑
</a>
<a href=https://www.cnblogs.com/ysocean/p/6870069.html>收藏</a></div>
 </div>
 
 
 </div>
</div>
<a name=!comments></a>
<div id=blog-comments-placeholder>
<div id=comment_pager_top>
 
</div>
<br>
<div class=feedback_area_title>评论列表</div>
<div class=feedbackNoItems><div class=feedbackNoItems></div></div> 
 <div class=feedbackItem>
 <div class=feedbackListSubtitle>
 <div class=feedbackManage>
 &nbsp;&nbsp;
<span class=comment_actions>
 
 
 
 
</span>
 </div>
 
<a href=#4020795 class=layer>#1楼</a>
<a name=4020795 id=comment_anchor_4020795></a>
 
<span class=comment_date>2018-07-15 18:44</span>
 
 <a id=a_comment_author_4020795 href=https://home.cnblogs.com/u/1442029/ target=_blank>知识付费</a>
 </div>
 <div class=feedbackCon>
 
<div id=comment_body_4020795 class=blog_comment_body>
 非常感谢
</div>
 <div class=comment_vote>
 <span class=comment_error style=color:red></span>
 <a href=https://www.cnblogs.com/ysocean/p/6870069.html class=comment_digg>
 支持(0)
 </a>
 <a href=https://www.cnblogs.com/ysocean/p/6870069.html class=comment_burry>
 反对(0)
 </a>
 </div>
 
 </div>
 </div>
 <div class=feedbackItem>
 <div class=feedbackListSubtitle>
 <div class=feedbackManage>
 &nbsp;&nbsp;
<span class=comment_actions>
 
 
 
 
</span>
 </div>
 
<a href=#4121105 class=layer>#2楼</a>
<a name=4121105 id=comment_anchor_4121105></a>
 
<span class=comment_date>2018-11-23 11:53</span>
 
 <a id=a_comment_author_4121105 href=https://home.cnblogs.com/u/1506897/ target=_blank>月落乌啼oez</a>
 </div>
 <div class=feedbackCon>
 
<div id=comment_body_4121105 class=blog_comment_body>
 感谢博主~
</div>
 <div class=comment_vote>
 <span class=comment_error style=color:red></span>
 <a href=https://www.cnblogs.com/ysocean/p/6870069.html class=comment_digg>
 支持(0)
 </a>
 <a href=https://www.cnblogs.com/ysocean/p/6870069.html class=comment_burry>
 反对(0)
 </a>
 </div>
 
 </div>
 </div>
 <div class=feedbackItem>
 <div class=feedbackListSubtitle>
 <div class=feedbackManage>
 &nbsp;&nbsp;
<span class=comment_actions>
 
 
 
 
</span>
 </div>
 
<a href=#4231444 class=layer>#3楼</a>
<a name=4231444 id=comment_anchor_4231444></a>
 <span id=comment-maxId style=display:none>4231444</span>
 <span id=comment-maxDate style=display:none>2019/4/15 下午3:02:24</span>
 
<span class=comment_date>2019-04-15 15:02</span>
 
 <a id=a_comment_author_4231444 href=https://home.cnblogs.com/u/1660423/ target=_blank>FelixLan</a>
 </div>
 <div class=feedbackCon>
 
<div id=comment_body_4231444 class=blog_comment_body>
 辛苦大佬了
</div>
 <div class=comment_vote>
 <span class=comment_error style=color:red></span>
 <a href=https://www.cnblogs.com/ysocean/p/6870069.html class=comment_digg>
 支持(0)
 </a>
 <a href=https://www.cnblogs.com/ysocean/p/6870069.html class=comment_burry>
 反对(0)
 </a>
 </div>
 
 </div>
 </div>
<div id=comment_pager_bottom>
 
</div>
</div>
<div id=comment_form class=commentform>
 <a name=commentform></a>
 <div id=divCommentShow></div>
 <div id=comment_nav><span id=span_refresh_tips></span><a href=https://www.cnblogs.com/ysocean/p/6870069.html id=lnk_RefreshComments runat=server clientidmode=Static>刷新评论</a><a href=#>刷新页面</a><a href=#top>返回顶部</a></div>
 <div id=comment_form_container><div class=login_tips>
 注册用户登录后才能发表评论，请 
 <a rel=nofollow href=https://www.cnblogs.com/ysocean/p/6870069.html class=underline>登录</a>
 或 
 <a rel=nofollow href=https://www.cnblogs.com/ysocean/p/6870069.html class=underline>注册</a>，
 <a href=https://www.cnblogs.com/>访问</a> 网站首页。
</div></div>
 <div class=ad_text_commentbox id=ad_text_under_commentbox></div>
 <div id=ad_t2><a href=http://www.ucancode.com/index.htm target=_blank>【推荐】超50万行VC++源码: 大型组态工控、电力仿真CAD与GIS源码库</a><br><a href="https://cloud.tencent.com/act/pro/overseas?fromSource=gwzcw.3090393.3090393.3090393&amp;utm_medium=cpc&amp;utm_id=gwzcw.3090393.3090393.3090393" target=_blank>【推荐】腾讯云海外1核2G云服务器低至2折，半价续费券限量免费领取！</a><br><a href=http://click.aliyun.com/m/1000081987/ target=_blank>【推荐】阿里云双11返场来袭，热门产品低至一折等你来抢！</a><br><a href="https://www.ctyun.cn/activity/20191111?hmsr=%E7%9C%8B%E7%9C%8B-%E5%8D%9A%E5%AE%A2%E5%9B%AD-%E5%8F%8C11-1106&amp;hmpl=&amp;hmcu=&amp;hmkw=&amp;hmci=" target=_blank>【推荐】天翼云双十一翼降到底，云主机11.11元起，抽奖送大礼</a><br><a href=https://www.uibot.com.cn/sem/bky.html target=_blank>【推荐】流程自动化专家UiBot，体系化教程成就高薪RPA工程师</a><br><a href="https://www.jdcloud.com/cn/activity/year-end?utm_source=DMT_cnblogs&amp;utm_medium=CH&amp;utm_campaign=q4vm&amp;utm_term=Virtual-Machines" target=_blank>【活动】京东云服务器_云主机低于1折，低价高性能产品备战双11</a><br><a href="https://www.qiniu.com/events/20191111?utm_campaign=2019_1111&amp;utm_content=cnblogs_1111&amp;utm_medium=banner&amp;utm_source=cnblogs&amp;utm_term=cnblogs_1111" target=_blank>【优惠】七牛云采购嘉年华，云存储、CDN等云产品低至1折</a><br></div>
 <div id=opt_under_post></div>
 
 
 
 <div id=cnblogs_c1 class="c_ad_block sf-hidden">
 <div id=div-gpt-ad-1546353474406-0 style=height:250px;width:300px></div>
 </div>
 <div id=under_post_news></div>
 <div id=cnblogs_c2 class="c_ad_block sf-hidden">
 <div id=div-gpt-ad-1539008685004-0 style=height:60px;width:468px>
 
 </div>
 </div>
 <div id=under_post_kb>
<div class="itnews c_ad_block sf-hidden">
 <b>最新 IT 新闻</b>:
 <br>
 · <a href=https://news.cnblogs.com/n/651458/ target=_blank>洋葱数学更名“洋葱学院”，拓展全年龄段全学科的K12业务</a>
 <br>
 · <a href=https://news.cnblogs.com/n/651457/ target=_blank>Aibee完成7400万美元A1轮融资，加速“精准零售”战略全面落地</a>
 <br>
 · <a href=https://news.cnblogs.com/n/651456/ target=_blank>.NET Core 3.1 发布，支持三年的 LTS 版本</a>
 <br>
 · <a href=https://news.cnblogs.com/n/651455/ target=_blank>皮查伊之下，谷歌的中国生意</a>
 <br>
 · <a href=https://news.cnblogs.com/n/651454/ target=_blank>棋手比赛一天消耗6000卡 但努力思考不能帮你减肥</a>
 <br>
 » <a href=https://news.cnblogs.com/ title="IT 新闻" target=_blank>更多新闻...</a>
</div></div>
 <div id=HistoryToday class="c_ad_block sf-hidden"></div>
 
</div>
 </div>
 </div>
 <div id=sideBar>
 <div id=sideBarMain>
 
<div id=sidebar_news class=newsItem>
<h3 class="catListTitle sf-hidden">公告</h3>
<div id=blog-news>
 <div style=display:none id=__document_write_ajax_div-1></div>
 <div id=profile_block>
 昵称：
 <a href=https://home.cnblogs.com/u/ysocean/>
 YSOcean
 </a>
 <br>
 园龄：
 <a href=https://home.cnblogs.com/u/ysocean/ title=入园时间：2017-03-07>
 2年8个月
 </a>
 <br>
 粉丝：
 <a href=https://home.cnblogs.com/u/ysocean/followers/>
 3709
 </a>
 <br>
 关注：
 <a href=https://home.cnblogs.com/u/ysocean/followees/>
 13
 </a>
 <div id=p_b_follow>
<a href=https://www.cnblogs.com/ysocean/p/6870069.html>+加关注</a></div>
 
 </div>
</div>
</div>
 <div id=blog-calendar>
<table id=blogCalendar class=Cal cellspacing=0 cellpadding=0 title=Calendar border=0>
 <tbody>
 <tr>
 <td colspan=7>
 <table class=CalTitle cellspacing=0 border=0>
 <tbody>
 <tr>
 <td class=CalNextPrev>
 <a href=https://www.cnblogs.com/ysocean/p/6870069.html>&lt;</a>
 </td>
 <td align=center>2019年12月</td>
 <td align=right class=CalNextPrev>
 <a href=https://www.cnblogs.com/ysocean/p/6870069.html>&gt;</a>
 </td>
 </tr>
 </tbody>
 </table>
 </td>
 </tr>
 <tr>
 <th class=CalDayHeader align=center abbr=日 scope=col>日</th>
 <th class=CalDayHeader align=center abbr=一 scope=col>一</th>
 <th class=CalDayHeader align=center abbr=二 scope=col>二</th>
 <th class=CalDayHeader align=center abbr=三 scope=col>三</th>
 <th class=CalDayHeader align=center abbr=四 scope=col>四</th>
 <th class=CalDayHeader align=center abbr=五 scope=col>五</th>
 <th class=CalDayHeader align=center abbr=六 scope=col>六</th>
 </tr>
 <tr>
 <td class=CalWeekendDay align=center>
 1
 </td>
 <td align=center>
 2
 </td>
 <td align=center>
 3
 </td>
 <td align=center>
 4
 </td>
 <td class=CalTodayDay align=center>
 5
 </td>
 <td align=center>
 6
 </td>
 <td class=CalWeekendDay align=center>
 7
 </td>
 </tr>
 <tr>
 <td class=CalWeekendDay align=center>
 8
 </td>
 <td align=center>
 9
 </td>
 <td align=center>
 10
 </td>
 <td align=center>
 11
 </td>
 <td align=center>
 12
 </td>
 <td align=center>
 13
 </td>
 <td class=CalWeekendDay align=center>
 14
 </td>
 </tr>
 <tr>
 <td class=CalWeekendDay align=center>
 15
 </td>
 <td align=center>
 16
 </td>
 <td align=center>
 17
 </td>
 <td align=center>
 18
 </td>
 <td align=center>
 19
 </td>
 <td align=center>
 20
 </td>
 <td class=CalWeekendDay align=center>
 21
 </td>
 </tr>
 <tr>
 <td class=CalWeekendDay align=center>
 22
 </td>
 <td align=center>
 23
 </td>
 <td align=center>
 24
 </td>
 <td align=center>
 25
 </td>
 <td align=center>
 26
 </td>
 <td align=center>
 27
 </td>
 <td class=CalWeekendDay align=center>
 28
 </td>
 </tr>
 <tr>
 <td class=CalWeekendDay align=center>
 29
 </td>
 <td align=center>
 30
 </td>
 <td align=center>
 31
 </td>
 <td class=CalOtherMonthDay align=center>
 1
 </td>
 <td class=CalOtherMonthDay align=center>
 2
 </td>
 <td class=CalOtherMonthDay align=center>
 3
 </td>
 <td class=CalOtherMonthDay align=center>
 4
 </td>
 </tr>
 <tr>
 <td class=CalOtherMonthDay align=center>
 5
 </td>
 <td class=CalOtherMonthDay align=center>
 6
 </td>
 <td class=CalOtherMonthDay align=center>
 7
 </td>
 <td class=CalOtherMonthDay align=center>
 8
 </td>
 <td class=CalOtherMonthDay align=center>
 9
 </td>
 <td class=CalOtherMonthDay align=center>
 10
 </td>
 <td class=CalOtherMonthDay align=center>
 11
 </td>
 </tr>
 </tbody>
</table></div>
 
 <div id=leftcontentcontainer>
 <div id=blog-sidecolumn>
<div id=sidebar_search class=sidebar-block>
 
</div>
<div id=sidebar_toptags class=sidebar-block>
 <div class=catListTag>
<h3 class=catListTitle>我的标签</h3>
<ul>
 <li>
 <a href=https://www.cnblogs.com/ysocean/tag/Linux%E7%B3%BB%E5%88%97%E6%95%99%E7%A8%8B/>Linux系列教程</a>(25)
 </li>
 <li>
 <a href=https://www.cnblogs.com/ysocean/tag/%E6%B7%B1%E5%85%A5%E7%90%86%E8%A7%A3%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%B3%BB%E7%BB%9F/>深入理解计算机系统</a>(24)
 </li>
 <li>
 <a href=https://www.cnblogs.com/ysocean/tag/Java%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E5%92%8C%E7%AE%97%E6%B3%95/>Java数据结构和算法</a>(17)
 </li>
 <li>
 <a href=https://www.cnblogs.com/ysocean/tag/Java%E8%99%9A%E6%8B%9F%E6%9C%BA%E8%AF%A6%E8%A7%A3/>Java虚拟机详解</a>(11)
 </li>
 <li>
 <a href=https://www.cnblogs.com/ysocean/tag/MyBatis%E8%AF%A6%E8%A7%A3%E7%B3%BB%E5%88%97/>MyBatis详解系列</a>(11)
 </li>
 <li>
 <a href=https://www.cnblogs.com/ysocean/tag/JDK%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/>JDK源码解析</a>(11)
 </li>
 <li>
 <a href=https://www.cnblogs.com/ysocean/tag/Maven%E7%B3%BB%E5%88%97%E6%95%99%E7%A8%8B/>Maven系列教程</a>(8)
 </li>
 <li>
 <a href=https://www.cnblogs.com/ysocean/tag/Redis%E8%AF%A6%E8%A7%A3/>Redis详解</a>(8)
 </li>
 <li>
 <a href=https://www.cnblogs.com/ysocean/tag/Spring%E5%85%A5%E9%97%A8%E7%B3%BB%E5%88%97/>Spring入门系列</a>(8)
 </li>
 <li>
 <a href=https://www.cnblogs.com/ysocean/tag/Java%20IO%E8%AF%A6%E8%A7%A3%E7%B3%BB%E5%88%97/>Java IO详解系列</a>(7)
 </li>
 <li>
 <a href=https://www.cnblogs.com/ysocean/tag/>更多</a>
 </li>
</ul>
</div>
</div>
<div id=sidebar_scorerank class=sidebar-block>
 <div class=catListBlogRank>
<h3 class=catListTitle>积分与排名</h3>
<ul>
 <li class=liScore>
 积分 - 
548954
 </li>
 <li class=liRank>
 排名 - 
374
 </li>
</ul>
</div>
</div>
<div id=sidebar_categories>
 
 <div id=sidebar_postcategory class="catListPostCategory sidebar-block">
 <h3 class=catListTitle>
 
随笔分类
 </h3>
 <ul>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/960781.html rel target>
 Java SE(22)
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/1007230.html rel target>
 JavaWeb(34)
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/1151280.html rel target>
 Java高并发
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/1170039.html rel target>
 Java关键字(6)
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/1120217.html rel target>
 Java数据结构和算法(15)
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/1151281.html rel target>
 Java虚拟机(10)
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/1149707.html rel target>
 JDK源码解析(12)
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/969991.html rel target>
 Linux(9)
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/1098949.html rel target>
 Linux详解(24)
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/1289968.html rel target>
 Nginx详解(4)
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/1221478.html rel target>
 Redis详解(8)
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/1151284.html rel target>
 TCP/IP协议
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/999300.html rel target>
 编程小技巧(1)
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/998919.html rel target>
 查找算法(1)
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/1015872.html rel target>
 大数据(3)
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/985981.html rel target>
 工具使用(16)
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/1075092.html rel target>
 计算机系统与结构(24)
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/1107855.html rel target>
 计算机组成与系统结构
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/1093310.html rel target>
 浪潮之巅(1)
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/999532.html rel target>
 排序算法
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/962747.html rel target>
 前端(5)
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/961408.html rel target>
 日常工作问题(7)
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/1005973.html rel target>
 设计模式(1)
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/1151283.html rel target>
 算法分析(1)
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/1243287.html rel target>
 消息中间件(6)
</a>
 
 </li>
 <li>
 
<a href=https://www.cnblogs.com/ysocean/category/1094464.html rel target>
 邮件服务(4)
</a>
 
 </li>
 </ul>
 </div>
</div>
<div id=sidebar_recentcomments class=sidebar-block>
 <div class=catListComment>
<h3 class=catListTitle>最新评论</h3>
 <div class=RecentCommentBlock>
 <ul>
 <li class=recent_comment_title><a href=https://www.cnblogs.com/ysocean/p/9143118.html#4449267>1. Re:Redis详解（八）------ 主从复制</a></li>
 <li class=recent_comment_body>博主的博客干货满满</li>
 <li class=recent_comment_author>--又是空白</li>
 <li class=recent_comment_title><a href=https://www.cnblogs.com/ysocean/p/9080942.html#4448293>2. Re:Redis详解（四）------ redis的底层数据结构</a></li>
 <li class=recent_comment_body>66</li>
 <li class=recent_comment_author>--shuibaicai</li>
 <li class=recent_comment_title><a href=https://www.cnblogs.com/ysocean/p/7894448.html#4447920>3. Re:Java数据结构和算法（二）——数组</a></li>
 <li class=recent_comment_body>干货，不过多些注释就更好了。比如size=索引+1<br>这样用size索引就更好理解了</li>
 <li class=recent_comment_author>--圆圆的大木头</li>
 <li class=recent_comment_title><a href=https://www.cnblogs.com/ysocean/p/9143118.html#4446716>4. Re:Redis详解（八）------ 主从复制</a></li>
 <li class=recent_comment_body>建议你把redis集群的cluster模式也写一下吧，做一个完整的系列，不过我觉得你写的已经很好很好了</li>
 <li class=recent_comment_author>--日才子素还真</li>
 <li class=recent_comment_title><a href=https://www.cnblogs.com/ysocean/p/7896269.html#4441254>5. Re:Java数据结构和算法（三）——冒泡、选择、插入排序算法</a></li>
 <li class=recent_comment_body>老铁 我看你博客里面的一些动态图 你是用什么软件去整的  求推荐 求分享</li>
 <li class=recent_comment_author>--道不尽</li>
 </ul>
 </div>
</div>
</div>
<div id=sidebar_topviewedposts class=sidebar-block>
 <div class=catListView>
<h3 class=catListTitle>阅读排行榜</h3>
 <div id=TopViewPostsBlock>
 <ul style=word-break:break-all>
 <li>
 <a href=https://www.cnblogs.com/ysocean/p/6893446.html>
 1. Tomcat 部署项目的三种方法(189400)
 </a>
 </li>
 <li>
 <a href=https://www.cnblogs.com/ysocean/p/6555373.html>
 2. Java 集合详解(114020)
 </a>
 </li>
 <li>
 <a href=https://www.cnblogs.com/ysocean/p/7889153.html>
 3. Java数据结构和算法（一）——简介(94114)
 </a>
 </li>
 <li>
 <a href=https://www.cnblogs.com/ysocean/p/7928988.html>
 4. Java数据结构和算法（七）——链表(92032)
 </a>
 </li>
 <li>
 <a href=https://www.cnblogs.com/ysocean/p/8486500.html>
 5. Java关键字(一)——instanceof(88127)
 </a>
 </li>
 </ul>
 </div>
</div>
</div>
</div>
 
 </div>
 
 </div>
 </div>
 <div class=clear></div>
 </div>
 <div class=clear></div>
 <div id=footer>
 
Copyright © 2019 YSOcean
<br><span id=poweredby>Powered by .NET Core 3.1.0 on Linux</span>
 </div>
</div>
 <div id=page_end_html>
 
 </div>
